#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    
/*
写1：abcd    abcd          0/4
写2：efghi   abcdefghi     0/9
读1：abcd    abcdefghi     4/5
写3：jklmno  mnodefghijkl  4/11
读2：efghi   mnodefghijkl  9/6
读3：jklmno  mnodefghijkl  3/0 
*/
    Buffer *buffer = app_buffer_init(12);
    // 写1：abcd    abcd          0/4
    app_buffer_write(buffer, "abcd", 4);
    // 写2：efghi   abcdefghi     0/9
    app_buffer_write(buffer, "efghi", 5);

    // 读1：abcd    abcdefghi     4/5
    char data[4];
    app_buffer_read(buffer, data, 4);
    log_debug("data=%s", data);

    // 写3：jklmno  mnodefghijkl  4/11
    app_buffer_write(buffer, "jklmno", 6);

    // 读2：efghi   mnodefghijkl  9/6
    char data2[5];
    app_buffer_read(buffer, data2, 5);
    log_debug("data2=%s", data2);

    // 读3：jklmno  mnodefghijkl  3/0 
    char data3[6];
    app_buffer_read(buffer, data3, 6);
    log_debug("data3=%s", data3);
    
    return 0;
}
